/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "stdafx.h"
#include "资产.h"

#include "intern/Vk单色材质.h"





static void f_updateGPU参数布局(S_材质* mat, S_GPU参数布局& layout, uint16 网格属性缓存槽数量) {
	
}

S_材质* f_create材质(S_设备环境& ctx, std::string name, E_MS次数 采样, std::string type, E_绘图API 后端) {
	S_材质* mat = new S_材质();

	S_线管创建参数 线管参数({ 1024, 576 });
	线管参数.m_绘制方式 = E_绘制方式::e_画连续线;
	线管参数.m_填充模式 = E_填充模式::e_填充线;
	线管参数.m_采样 = 采样;

	S_线管创建配置 图元配置;

	if (type == "单色面材质") {
		图元配置 = {
			{
				{0, E_着色阶段::e_顶点着色, E_板载缓存类型::e_UBO},
				{1, E_着色阶段::e_顶点着色, E_板载缓存类型::e_SSBO},
			},
			{
				{0,sizeof(vec3),0,E_数据格式::e_F_RGB},
				//{0,sizeof(vec3),0,E_数据格式::e_F_R32G32B32},
			},
			{
				{"D:/U/Project/engine/资产/着色/compiled/纯色面绘制_顶点阶段.spv", E_着色阶段::e_顶点着色},
				{"D:/U/Project/engine/资产/着色/compiled/纯色面绘制_片源阶段.spv", E_着色阶段::e_像素着色},
			}
		};
	}
	else if (type == "光照面材质") {
		图元配置 = {
			{
				{0, E_着色阶段::e_顶点着色, E_板载缓存类型::e_UBO},
				{1, E_着色阶段::e_顶点着色, E_板载缓存类型::e_SSBO},
				{2, E_着色阶段::e_顶点着色, E_板载缓存类型::e_SSBO},
			},
			{
				{0,sizeof(vec3),0,E_数据格式::e_F_RGB},
				{0,sizeof(vec3),0,E_数据格式::e_F_RGB},
			},
			{
				{"D:/U/Project/engine/资产/着色/compiled/基本光照_顶点阶段.spv", E_着色阶段::e_顶点着色},
				{"D:/U/Project/engine/资产/着色/compiled/基本光照_片源阶段.spv", E_着色阶段::e_像素着色},
			}
		};

		线管参数.m_绘制方式 = E_绘制方式::e_三角形;
		线管参数.m_填充模式 = E_填充模式::e_填充面;
	}
	else if (type == "光照纹理面材质") {

	}


	auto* Shader = f_create着色(ctx, 图元配置);
	auto* 线管 = f_create线管(ctx, *Shader, 线管参数);

	mat->m_Pipeline = 线管;
	mat->m_Shader = Shader;
	mat->mf_GPU材质槽更新 = f_updateGPU参数布局;
	return mat;
}

S_材质* f_create基本材质(E_基本材质类型 type, std::string name, E_绘图API 后端) {
	S_材质* mat = new S_材质();

	return mat;
}

S_材质* f_create基本材质(S_着色* shader, S_线管* 线管, E_绘图API 后端) {
	S_材质* mat = new S_材质();

	mat->m_Pipeline = 线管;
	mat->m_Shader = shader;

	shader->f_alloc参数设置(&(mat->m_GPU参数set));

	return mat;
}






